#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import codecs
from xml.dom import minidom
import fanfou


htmldoc = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<title>HTML</title>
</head>
<table border="1">'''
xmldoc = fanfou.getXmlFriendTL()
statuslist = xmldoc.getElementsByTagName('status')
for status in statuslist:
	user = status.getElementsByTagName('user')
	userName = user[0].getElementsByTagName('name')
	userText = status.getElementsByTagName('text')
	htmldoc = htmldoc + '<tr>\n<td>' + userName[0].firstChild.data.encode('utf-8') + '</td>\n<td>' + userText[0].firstChild.data.encode('utf-8') + '</td>\n</tr>'
htmldoc = htmldoc + '</table>'
print htmldoc

f = codecs.open('tl.html', 'w', 'utf-8')
f.write(htmldoc.decode('utf-8'))
f.close()

#if __name__ == '__main__':
#	main()

